
<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
	<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>注册</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="description" content="Free HTML5 Template by FreeHTML5.co" />
	<meta name="keywords" content="free html5, free template, free bootstrap, html5, css3, mobile first, responsive" />
	<meta name="author" content="FreeHTML5.co" />
		<link rel='stylesheet' href='/css/bootstrap.min.css'>
		<link rel="stylesheet" href="/css/style.css">
		<link rel="stylesheet" href="/layui/css/layui.css">

		<link rel="stylesheet" href="/css/animate.css">
		<script src="/common/commonJS.js"></script>
	<![endif]-->

	</head>
	<body>

		<div class="container">
			<div class="row">
				<div class="col-md-4 col-md-offset-4">
					<!-- Start Sign In Form -->
					<form action="#" class="fh5co-form animate-box layui-form" data-animate-effect="fadeIn" id="registerForm">
						<h2>Sign Up</h2>
						<div class="form-group layui-form-item">
							<label for="name" class="sr-only">Name</label>
							<input type="text" class="form-control" id="name" name="username" lay-verify="required"  placeholder="Name" autocomplete="off">
						</div>
						<div class="form-group layui-form-item">
							<label for="password" class="sr-only">Password</label>
							<input type="password" class="form-control" id="password" name="password" lay-verify="required" placeholder="Password" autocomplete="off">
						</div>
						<div class="form-group layui-form-item">
							<label for="re-password" class="sr-only">Re-type Password</label>
							<input type="password" class="form-control" id="re-password" name="repassword" lay-verify="required" placeholder="Re-type Password" autocomplete="off">
						</div>
						<div class="form-group layui-form-item">
							<p>Already registered? <a href="/login">Sign In</a></p>
						</div>
						<div class="form-group layui-form-item">
							<button class="layui-btn layui-btn-primary layui-btn-radius" id="submit" lay-submit=""  type="submit" lay-filter="submitRegister" >注册</button>
						</div>
					</form>
					<!-- END Sign In Form -->

				</div>
			</div>
			<div class="row" style="padding-top: 60px; clear: both;">
				<div class="col-md-12 text-center"><p><small></small></p></div>
			</div>
		</div>


		<script>
			layui.use(['layer', 'form'], function () {

				var form = layui.form,layer = layui.layer;
				var url = "http://localhost:8080/";

				form.verify({

				});

				form.on('submit(submitRegister)', function (data) {
					//表单数据formData
					var formData = data.field;

					console.log(formData.password);
					if(formData.password != formData.repassword){
						console.log("buxiandgeng");
						layer.msg("密码不一致")
						return false;
					}

					$.ajax({
						type:"get",
						data:formData,
						url:url+"registerAction",
						error:function (XMLHttpRequest,textStatus,errorThrown) {
							layer.alert("执行失败，"+XMLHttpRequest.status+"--"+XMLHttpRequest.readyState);
						},

						success:function (data) {
							console.log(data);
							if(data.success){
								console.log(data);
								location.href = url ;
								layer.msg(data.msg);
							} else {
								layer.msg(data.msg);
							}

						}

					});

					return false;
				});

			});
		</script>


	</body>
</html>

